/***********************************************************************
 * Module:  AbstractNetworkLayer.java
 * Author:  Mladen
 * Purpose: Defines the Class AbstractNetworkLayer
 ***********************************************************************/

package raf.core;

public abstract class AbstractNetworkLayer implements NetworkLayerInterface {

	public java.util.Collection<NodeInterface> nodeInterface;

	public java.util.Collection getNodeInterface() {
		if (nodeInterface == null)
			nodeInterface = new java.util.HashSet<NodeInterface>();
		return nodeInterface;
	}

	public java.util.Iterator getIteratorNodeInterface() {
		if (nodeInterface == null)
			nodeInterface = new java.util.HashSet<NodeInterface>();
		return nodeInterface.iterator();
	}

	public void setNodeInterface(java.util.Collection newNodeInterface) {
		removeAllNodeInterface();
		for (java.util.Iterator iter = newNodeInterface.iterator(); iter
				.hasNext();)
			addNodeInterface((NodeInterface) iter.next());
	}

	public void addNodeInterface(NodeInterface newNodeInterface) {
		if (newNodeInterface == null)
			return;
		if (this.nodeInterface == null)
			this.nodeInterface = new java.util.HashSet<NodeInterface>();
		if (!this.nodeInterface.contains(newNodeInterface))
			this.nodeInterface.add(newNodeInterface);
	}

	public void removeNodeInterface(NodeInterface oldNodeInterface) {
		if (oldNodeInterface == null)
			return;
		if (this.nodeInterface != null)
			if (this.nodeInterface.contains(oldNodeInterface))
				this.nodeInterface.remove(oldNodeInterface);
	}

	public void removeAllNodeInterface() {
		if (nodeInterface != null)
			nodeInterface.clear();
	}

}